/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package codeclz77.bean;

import java.util.Deque;
import java.util.List;

/**
 *
 * @author Douglas
 */
public class Lz77 {
// Quantidade máxima de caracteres que vai olhar para trás (limite em 65365)    
    private char searchBuffer;
// Quantidade máxima de caracteres que vai olhar para frente (limite em 65365)    
    private char lookAhead;
// Buffer de caracteres no qual está fazendo a codificação (searchBuffer + lookAhead)    
    public Deque<Character> buffer;
// Indica a posição atual do ponteiro no buffer para controle de searchBuffer
    private int pointer;

    private List<Triplet> triplets;

    public Lz77() {
    }
    
    public Lz77(char searchBuffer, char lookAhead, Deque<Character> buffer, int pointer, List<Triplet> triplets) {
        this.searchBuffer = searchBuffer;
        this.lookAhead = lookAhead;
        this.buffer = buffer;
        this.pointer = pointer;
        this.triplets = triplets;
    }

    /**
     * @return the searchBuffer
     */
    public char getSearchBuffer() {
        return searchBuffer;
    }

    /**
     * @param searchBuffer the searchBuffer to set
     */
    public void setSearchBuffer(char searchBuffer) {
        this.searchBuffer = searchBuffer;
    }

    /**
     * @return the lookAhead
     */
    public char getLookAhead() {
        return lookAhead;
    }

    /**
     * @param lookAhead the lookAhead to set
     */
    public void setLookAhead(char lookAhead) {
        this.lookAhead = lookAhead;
    }

    /**
     * @return the buffer
     */
    public Deque getBuffer() {
        return buffer;
    }

    /**
     * @param buffer the buffer to set
     */
    public void setBuffer(Deque buffer) {
        this.buffer = buffer;
    }

    /**
     * @return the triplets
     */
    public List getTriplets() {
        return triplets;
    }

    /**
     * @param triplets the triplets to set
     */
    public void setTriplets(List triplets) {
        this.triplets = triplets;
    }

    /**
     * @return the pointer
     */
    public int getPointer() {
        return pointer;
    }

    /**
     * @param pointer the pointer to set
     */
    public void setPointer(int pointer) {
        this.pointer = pointer;
    }

    public void addBuffer(char newSymbol) {
        buffer.add(newSymbol);
    }

    public int getBufferSize() {
        return buffer.size();
    }

    public boolean swapBuffer() {
        if(buffer.removeLast() == null) return true;
        return false;
    }
    
    public void addTriplet(Triplet t){
        triplets.add(t);
    }
    
    public List<Triplet> getTriplet(){
        return triplets;
    }
    
    
    
    
}
